package com.invengo.module_check.ui.fragment.home;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableList;

import com.invengo.module_check.BR;
import com.invengo.module_check.R;
import com.invengo.module_check.data.entity.FeatureBean;
import com.invengo.module_check.data.repsitory.common.CommonRepsitory;
import com.invengo.library_rfid.entity.TagInfo;

import java.util.List;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent;
import me.goldze.mvvmhabit.utils.cache.ACache;
import me.goldze.mvvmhabit.utils.cache.AKey;
import me.tatarka.bindingcollectionadapter2.ItemBinding;

public class HomeViewModel extends BaseViewModel<CommonRepsitory> {
    public SingleLiveEvent<FeatureBean> itemClickEvent = new SingleLiveEvent<>();

    public HomeViewModel(@NonNull Application application) {
        super(application);
        List<FeatureBean> list= (List<FeatureBean>) ACache.getInstance().getAsObject(AKey.CACHE_FEATURE_LIST);
        for (FeatureBean featureBean : list) {
            if (featureBean.isOpen()){
                observableList.add(new HomeItemViewModel(this,featureBean));
            }
        }
    }
    //给RecyclerView添加ObservableList


    @Override
    public void onCreate() {
        super.onCreate();

    }

    public ObservableList<HomeItemViewModel> observableList = new ObservableArrayList<>();
    //给RecyclerView添加ItemBinding
    public ItemBinding<HomeItemViewModel> itemBinding = ItemBinding.of(BR.viewModel, R.layout.item_home);
}
